<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script src="/js/jquery.min.js"></script>
  <title>康佳智电</title>

  <style>
	*{
		margin:0;
		padding:0;
	}
	a{
	
	text-decoration:none;
	-webkit-tap-highlight-color:rgba(255,0,0,0);
	}
	a:link{color:#666;}
	a:visited{color:#666;}
	a:hover{color:#666;}
	a:active{color:#23D1F5;}
	html{
		font-family:"微软雅黑";
		font-size:20px;
		color:#666;
	}
	header{
		width:15rem;
		font-size:.8rem;
		border-bottom:1px solid #666;
		margin:.6rem auto;
		padding-bottom:.5rem;
		font-weight:600;
		
	}
	.text_content p{
		font-size:.58rem;
		padding:.5rem;
	
		
	}
	footer {
		width:12rem;
		position:absolute;
		left:0;
		right:0;
		margin:auto;
		bottom:1rem;
	}
	footer section {
		float:left;
		width:6rem;
		text-align:center;
		font-size:.8rem;
	}
	footer section a{display: block;}
	footer section img{width:35%;}

	.hint_bg,.hint_bg1{
		width:16rem;
		background: rgba(0,0,0,.5);
		position: absolute;
		top: 0;
		left: 0;
		z-index: 100000000;
		display: none;
		font-size: .8rem;
	}
	.hint_box,.hint_box1{
		width: 10rem;
		height: 6rem;
		background: #fff;
		position: absolute;
		text-align: center;
		top: 0;
		left: 0;
		right: 0;
		bottom:0;
		margin:auto;
	}
	.hint_bg .hint_box p,.hint_bg1 .hint_box1 .hint_text1{
		margin-top: 1rem;
	}
	.hint_bg .hint_box section{
		width:5rem;
		margin:1.2rem auto; 
		border:1px solid #ccc;
		padding: .3rem 0;
		border-radius:.3rem;
	}
  </style>
 </head>
 <body>
	<input type="hidden" value="{{$jssdkSignPackage['appId'] or 123 }}" class="appId_val" />
	<input type="hidden" value="{{$jssdkSignPackage['nonceStr'] or 123 }}" class="nonceStr_val" />
	<input type="hidden" value="{{$jssdkSignPackage['timestamp'] or 123 }}" class="timestamp_val" />
	<input type="hidden" value="{{$jssdkSignPackage['signature'] or 123 }}" class="signature_val" />
	<header>绑定指引</header>
	<section class="text_content">
		<p>您还没有绑定设备，请按如下方式设置联网并绑定设备：</p>
		<p>1.确保手机连上网络。</p>
		<p>2.童锁状态下长按“热水键”3秒，<img src="/img/wifi_logo.png" />指示灯闪烁。</p>
		<p>3.点击本页“设置网络”按钮，输入网络密码。</p>
		<p>4.点击“绑定水机“按钮，扫描二维码绑定设备。</p>
	</section>
	<input type="hidden" value="{{ $status['message'] or '' }}" class="hint_infor" />
	<footer>
		<section id="set_net">
			<img src="/img/wifi_logo2.png" />
			<a>设置网络</a>
		</section>
		<section id="scan">
			<img src="/img/add_logo.png" />
			<a>绑定水机</a>
		</section>
	</footer>
	<!-- 提交信息服务器反馈信息-->
	<section class="hint_bg">
		<section class="hint_box">
			<p class="hint_text"></p>
			<section class="hint_btn">确定</section>
		</section>
	</section>
	<section class="hint_bg1">
        <section class="hint_box1">
            <p class="hint_text1"></p>
        </section>
    </section>
	<script src="/js/publick.js"></script>
	<script src="/js/jquery.min.js"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script>
		$(function(){
			wx.config({
				beta:true,
				debug:false,
				appId:$('.appId_val').val(),
				timestamp:$('.timestamp_val').val(),
				nonceStr:$('.nonceStr_val').val(),
				signature:$('.signature_val').val(),
				jsApiList:['configWXDeviceWiFi', 'scanQRCode']
			});
		});

			var hint_data = $('.hint_infor').val();
			hint(hint_data);
			$("#set_net").click(function(){
					
				wx.ready(function(){
					wx.invoke('configWXDeviceWiFi',{
					},function(res){
						switch (res.err_msg){
							case 'configWXDeviceWiFi:ok':
								hint('配置成功');
								break;
							case 'configWXDeviceWiFi:fail':
								hint('配网超时');
								break;
							case 'configWXDeviceWiFi:cancel':
								hint('用户取消配网');
								break;
							default:
								hint("res.err_msg:" + res.err_msg + "\nres.desc:" + res.desc);
						}
					});
				});
			});
			//sao yi sao 
			$("#scan").click(function(){
				wx.scanQRCode({
				    needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
				    scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
				    success: function (res) {
				    	if (res.errMsg === "scanQRCode:ok"){
					    	// 当needResult 为 1 时，扫码返回的结果
						    $.ajax({
						    	url:"/api/device/bind",
						    	type:"post",
						    	data:{device_code:res.resultStr},
						    	dataType:'json',
						    	success:function(data){
						    		if(data.status.errCode == 0||data.status.errCode == 2001){
						    			hint("绑定成功!");
				    					setTimeout(function(){
				    						window.location.href = "{{url('device/index')}}?"+new Date().getTime();
				    					},300);
						    		}else{					    			
						    			hint(data.status.message);
						    		}
						    	},
						    	error:function(jqXHR, textStatus, errorThrown){
				    				hint("绑定失败" + jqXHR.status + textStatus + errorThrown);
						    		//console.log(jqXHR.status);
						    	}
						    });
					    }
					}
				});
			});
	</script>
 </body>
</html>